﻿GroupListView = Backbone.View.extend
({
    OnRenderProjectHandler: null,
    initialize: function ()
    {
        this.AddEvents();

        this.trigger(this.OnRenderProjectHandler);
    },
    AddEvents: function ()
    {
    },
    RenderProjects: function (lstProjects)
    {
        $("#tblProjects").html("");

        var i = 0;
        var total = lstProjects.length;

        var row = "";
        var data = "";
        var item;
        for (i = 0; i < total; i++)
        {
            item = lstProjects[i];
            row = "<div class='MainTable-Cell'>";
            row += item.Name;
            row += "<input type='hidden' value='" + item.Id + "'/>";
            row += "<img src='Images/" + item.Logo + "'>";
            row += "</div>";

            data += row;
        }

        $("#tblProjects").html(data);

        $("#tblProjects .MainTable-Cell").click(jQuery.proxy(this.OnSelectProject, this));
    },
    OnSelectProject: function (evt)
    {
        var id = $(evt.target).children('input')[0].value;

        window.location = "MatchList.aspx?ID=" + id;
    }

});